package dao

import javax.inject.Inject

import models.Tables.Submission
import play.api.db.slick.{DatabaseConfigProvider, HasDatabaseConfigProvider}
import slick.jdbc.JdbcProfile

import scala.concurrent.Future
import models.Tables._
import scala.concurrent.ExecutionContext.Implicits.global

class VisitorDao  @Inject()(protected val dbConfigProvider: DatabaseConfigProvider) extends
  HasDatabaseConfigProvider[JdbcProfile] {

  import profile.api._

  def insertOrUpdate(row: VisitorRow): Future[Unit] = {
    db.run(Visitor.insertOrUpdate(row)).map(_ => ())
  }

  def selectAll: Future[Seq[VisitorRow]] = {
    db.run(Visitor.result)
  }

}
